Datastore = require('nedb')
config = require('./../config/config')

db = {}
dbPath = config.dbFilePath

db.users = new Datastore(dbPath + 'users.db')
db.users.loadDatabase();
db.tasks = new Datastore(dbPath + 'task.db')
db.tasks.loadDatabase();

#初始化一个用户
#db.users.findOne({username: 'admin'}, (err, user)->
#  return console.log(err) if err
#  return console.log('用户已存在，无需初始化！') if user
#  db.users.insert({username: 'admin', password: '123'})
#)

#db.users=new Datastore({filename:'path/to/datafile',autoload:true})

module.exports = db;